import request from '@/utils/request';

//查询发货通知列表
export function listNotice(query) {
    return request({
        url: '/system/productOutRelease/getList',
        method: 'get',
        params: query
    })
}

// 查询发货通知详细信息
export function detailNotice(id) {
    return request({
        url: '/system/productOutRelease/getInfo?id=' + id,
        method: 'get'
    })
}

// 查询收货人列表
export function listAddress(data) {
    return request({
        url: 'system/address/list',
        method: 'get',
        params: data
    })
}

// 新建发货通知
export function addNotice(data) {
    return request({
        url: '/system/productOutRelease/add',
        method: 'post',
        data: data
    })
}

// 获取storeId
export function getStoreId(id, number) {
    return request({
        url: '/system/productOutRelease/getStore?productId=' + id + '&batchNumber=' + number,
        method: 'get'
    })
}

// 获取可通知数量
export function getAllowCount(id) {
    return request({
        url: '/system/productOutRelease/getAllowCount?storeId=' + id,
        method: 'get'
    })
}

// 编辑发货通知
export function editNotice(data) {
    return request({
        url: '/system/productOutRelease/edit',
        method: 'post',
        data: data
    })
}

// 取消发货通知
export function cancelNotice(id) {
    const data = {
        id
    }
    return request({
        url: '/system/productOutRelease/recallNotice',
        method: 'post',
        data: data
    })
}

// 发货通知
export function sendNotice(id, name, telephone, address, planStoreOut, allowCount) {
    const data = {
        id,
        name,
        telephone,
        address,
        planStoreOut,
        allowCount
    }
    return request({
        url: '/system/productOutRelease/sendProduct',
        method: 'post',
        data: data
    })
}

// 拆单
export function orderNotice(id, name, telephone, address, planStoreOut, allowCount) {
    const data = {
        id,
        name,
        telephone,
        address,
        planStoreOut,
        allowCount
    }
    return request({
        url: '/system/productOutRelease/splitOrder',
        method: 'post',
        data: data
    })
}


// 新建oem发货通知
export function addOemNotice(data) {
    return request({
        url: '/system/productOutRelease/addNew',
        method: 'post',
        data: data
    })
}

// 查询oem发货通知详细信息
export function detailOemNotice(id) {
    return request({
        url: '/system/productOutRelease/selectOne?id=' + id,
        method: 'get'
    })
}

// oem发货通知
export function sendOemNotice(data) {
    return request({
        url: '/system/productOutRelease/notice',
        method: 'post',
        data: data
    })
}

// oem取消发货通知
export function cancelOemNotice(id) {
    const data = {
        id
    }
    return request({
        url: '/system/productOutRelease/revoke',
        method: 'post',
        data: data
    })
}